import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
import VueRouter from 'vue-router'
import {routes} from './routes/route'
import {store} from './store/store'
import axios from 'axios'
import VueAxios from 'vue-axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import VueQuillEditor from 'vue-quill-editor'



Vue.use(ElementUI)

Vue.use(VueRouter)

Vue.use(NProgress)

Vue.use(VueAxios,axios)

Vue.use(require('vue-moment'))

Vue.use(VueQuillEditor)



const router = new VueRouter({
    routes:routes,
    mode:'history',
})

router.beforeEach((to,from,next)=>{
  window.scroll(0,0);
  var login = store.state.login;
  if(!login && to.path !== "/login"){
    next('/login')
  }else{
    NProgress.start();
    next();
  }
  
})

router.afterEach(transition =>{
  NProgress.done();
})


new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
